import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../views/Layout.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    // redirect: '/home',
    component: Layout,
    // children: [
    //   {
    //     path: '/login',
    //     component: () => import('../login/Login.vue'),
    //   },
    //   {
    //     path: '/home',
    //     component: () => import('../echarts/pie.vue'), // 框架页
    //   },
    // ],
  },
  {
    path: '/second',
    meta: {
      icon: 'el-icon-tools',
      title: '二次封装',
    },
    component: Layout,
    children: [
      {
        path: 'navside',
        meta: {
          title: '侧边',
          icon: 'el-icon-bicycle',
        },
        component: () => import('../views/Side.vue'),
      },
      {
        path: 'icons',
        meta: {
          title: '图标选择',
          icon: 'el-icon-icetea',
        },
        component: () => import('../views/ChooseIcon.vue'),
      },
      {
        path: 'area',
        meta: {
          title: '地区选择',
          icon: 'el-icon-addlocation',
        },
        component: () => import('../views/ChooseArea.vue'),
      },
      {
        path: 'trend',
        meta: {
          title: '趋势图标',
          icon: 'el-icon-addlocation',
        },
        component: () => import('../views/Trend.vue'),
      },
      {
        path: 'notification',
        meta: {
          title: '通知',
          icon: 'el-icon-bellfilled',
        },
        component: () => import('../views/Notification.vue'),
      },
      {
        path: 'menu',
        meta: {
          title: '菜单',
          icon: 'el-icon-menu',
        },
        component: () => import('../views/Menu.vue'),
      },
      {
        path: 'progress',
        meta: {
          title: '动画进度条',
          icon: 'el-icon-darrowright',
        },
        component: () => import('../views/Progress.vue'),
      },
      {
        path: 'chooseCity',
        meta: {
          title: '城市选择',
          icon: 'el-icon-shop',
        },
        component: () => import('../views/ChooseCity.vue'),
      },
      {
        path: 'form',
        meta: {
          title: '表单',
          icon: 'el-icon-scaletooriginal',
        },
        component: () => import('../views/Form.vue'),
      },
      {
        path: 'dialogForm',
        meta: {
          title: '弹窗表单',
          icon: 'el-icon-hotwater',
        },
        component: () => import('../views/DialogForm.vue'),
      },
      {
        path: 'table',
        meta: {
          title: '表格',
          icon: 'el-icon-creditcard',
        },
        component: () => import('../views/Table.vue'),
      },
    ],
  },
  {
    path: '/official_account',
    component: Layout,
    meta: {
      icon: 'el-icon-menu',
      title: '微服务公众号',
    },
    children: [
      {
        path: 'user',
        component: () => import('../official_account/user.vue'),
        meta: {
          icon: 'el-icon-user',
          title: '用户列表',
        },
      },
      {
        path: 'tag',
        component: () => import('../official_account/tag.vue'),
        meta: {
          icon: 'el-icon-turnOff',
          title: '标签列表',
        },
      },
      {
        path: 'msg',
        component: () => import('../official_account/message.vue'),
        meta: {
          icon: 'el-icon-messageBox',
          title: '推送消息',
        },
      },
    ],
  },
  {
    path: '/table',
    component: Layout,
    meta: {
      icon: 'el-icon-menu',
      title: 'table演示',
    },
    children: [
      {
        path: 'base',
        component: () => import('../vxe_table/table.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '基础表格',
        },
      },
      {
        path: 'config',
        component: () => import('../vxe_table/table_config.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '表格配置',
        },
      },
      {
        path: 'sort',
        component: () => import('../vxe_table/table_sort.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '表格排序',
        },
      },
      {
        path: 'filter',
        component: () => import('../vxe_table/table_filter.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '表格筛选',
        },
      },
      {
        path: 'formatter',
        component: () => import('../vxe_table/table_format.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '格式化',
        },
      },
      {
        path: 'model',
        component: () => import('../vxe_table/table_custom_model.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '自定义模板',
        },
      },
      {
        path: 'merge',
        component: () => import('../vxe_table/table_merge.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '合并',
        },
      },
      {
        path: 'impexp',
        component: () => import('../vxe_table/table_imp_exp.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '导入导出',
        },
      },
      {
        path: 'edit',
        component: () => import('../vxe_table/table_edit.vue'),
        meta: {
          icon: 'el-icon-table',
          title: '编辑',
        },
      },
    ],
  },
  {
    path: '/grid',
    component: Layout,
    meta: {
      icon: 'el-icon-menu',
      title: 'grid演示',
    },
    children: [
      {
        path: 'proxy',
        component: () => import('../vxe_table/grid_proxy.vue'),
        meta: {
          icon: 'el-icon-proxy',
          title: '数据代理',
        },
      },
      {
        path: 'page',
        component: () => import('../vxe_table/grid_page.vue'),
        meta: {
          icon: 'el-icon-page',
          title: '分页',
        },
      },
      {
        path: 'form',
        component: () => import('../vxe_table/grid_form.vue'),
        meta: {
          icon: 'el-icon-form',
          title: '表单',
        },
      },
      {
        path: 'full',
        component: () => import('../vxe_table/grid_full.vue'),
        meta: {
          icon: 'el-icon-all',
          title: '完整功能',
        },
      },
    ],
  },
  {
    path: '/spreadjs',
    component: () => import('../spreadjs/spreadjs.vue'),
    meta: {
      title: 'excel表格',
    },
  },
  {
    path: '/tablespace',
    // redirect: '/tablespace/monitor',
    component: Layout,
    meta: {
      icon: 'el-icon-histogram',
      title: '监控',
    },
    children: [
      {
        path: 'chart',
        component: () => import('../echarts/Kandle.vue'),
        meta: {
          icon: 'el-icon-histogram',
          title: '大屏',
        },
      },
      {
        path: 'monitor',
        component: () => import('../tablespace_monitor/view.vue'),
        meta: {
          icon: 'el-icon-histogram',
          title: '监控1',
        },
      },
    ],
  },
]

const router = createRouter({
  routes,
  history: createWebHashHistory(),
})

// 挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') return next()
//   // 获取token
//   const tokenStr = window.sessionStorage.getItem('token')
//   if (!tokenStr) {
//     return next('/login')
//   }
//   next()
// })

export default router
